<html>
<head><meta charset="utf-8"><title>Don&#x27;t steal the resolver when lowering HI… compiler-team#437 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html">Don&#x27;t steal the resolver when lowering HI… compiler-team#437</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241669736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241669736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241669736">(Jun 06 2021 at 03:36)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/compiler-team/issues/437">Don't steal the resolver when lowering HIR; instead look resolution info up on-demand #437</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="241669799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241669799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241669799">(Jun 06 2021 at 03:39)</a>:</h4>
<p>I have some (very broken) WIP code, I will try to push it somewhere before I go to bed so you can get an idea of what the changes look like. I don't yet know how to access the Queries struct in TyCtxt, does anyone know how?</p>



<a name="241669874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241669874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241669874">(Jun 06 2021 at 03:41)</a>:</h4>
<p>(happy to move this to <a class="stream" data-stream-id="182449" href="/#narrow/stream/182449-t-compiler.2Fhelp">#t-compiler/help</a> if you want to keep this stream focused on whether this is a good idea or not)</p>



<a name="241671353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241671353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241671353">(Jun 06 2021 at 04:13)</a>:</h4>
<p>the other thing I just ran into is I don't know how to get a &amp;Resolver from a &amp;BoxedResolver (<code>.access()</code> requires <code>&amp;mut BoxedResolver</code>). This seems like it should be possible but <code>declare_box_region_type </code> in rustc_data_structures is a nightmare of keywords</p>



<a name="241671645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241671645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241671645">(Jun 06 2021 at 04:20)</a>:</h4>
<p>Have you seen <a href="https://github.com/rust-lang/rust/pull/85885">https://github.com/rust-lang/rust/pull/85885</a>?</p>



<a name="241671659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241671659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241671659">(Jun 06 2021 at 04:21)</a>:</h4>
<p>I have not! Thank you <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="241672008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672008">(Jun 06 2021 at 04:30)</a>:</h4>
<p>I would really like if <code>TyCtxt</code> keeps using <code>ResolverOutputs</code> as input instead of <code>Resolver</code>. It saves memory and provides a really nice abstraction point to decouple the frontend (everythjng before HIR) from the middle end (everything with HIR before codegen) and would theoretically allow for example plugging in a frontend for a rust like language or using completely different frontends for different editions.</p>



<a name="241672078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672078">(Jun 06 2021 at 04:33)</a>:</h4>
<p>What do you think about this setup?</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs</span>
<span class="gh">index 970e669c16f..cf3e9109910 100644</span>
<span class="gd">--- a/compiler/rustc_middle/src/ty/context.rs</span>
<span class="gi">+++ b/compiler/rustc_middle/src/ty/context.rs</span>
<span class="gu">@@ -932,6 +932,10 @@ fn deref(&amp;self) -&gt; &amp;Self::Target {</span>
     }
 }

<span class="gi">+pub trait Resolver {</span>
<span class="gi">+    fn resolver_outputs(&amp;self) -&gt; &amp;ty::ResolverOutputs;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
 pub struct GlobalCtxt&lt;'tcx&gt; {
     pub arena: &amp;'tcx WorkerLocal&lt;Arena&lt;'tcx&gt;&gt;,

<span class="gu">@@ -1129,7 +1133,7 @@ pub fn create_global_ctxt(</span>
         s: &amp;'tcx Session,
         lint_store: Lrc&lt;dyn Any + sync::Send + sync::Sync&gt;,
         arena: &amp;'tcx WorkerLocal&lt;Arena&lt;'tcx&gt;&gt;,
<span class="gd">-        resolutions: ty::ResolverOutputs,</span>
<span class="gi">+        resolver: &amp;'tcx impl Resolver,</span>
         krate: &amp;'tcx hir::Crate&lt;'tcx&gt;,
         dep_graph: DepGraph,
         on_disk_cache: Option&lt;query::OnDiskCache&lt;'tcx&gt;&gt;,
</code></pre></div>
<p>that keeps the abstraction boundary while still not requiring the outputs to be cloned</p>



<a name="241672161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672161">(Jun 06 2021 at 04:34)</a>:</h4>
<blockquote>
<p>would theoretically allow for example plugging in a frontend for a rust like language or using completely different frontends for different editions.</p>
</blockquote>
<p>this isn't possible even today, rustdoc wouldn't work with the other frontend</p>



<a name="241672165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672165">(Jun 06 2021 at 04:34)</a>:</h4>
<p>exactly because it uses the Resolver directly</p>



<a name="241672180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672180">(Jun 06 2021 at 04:35)</a>:</h4>
<p><code>trait Resolver</code> could work, but I don't know if the overhead isn't too high.</p>



<a name="241672227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672227">(Jun 06 2021 at 04:36)</a>:</h4>
<p>While rustdoc wouldn't support it, rustc should support alternative frontends without too much changes to rustc_interface already I think.</p>



<a name="241672229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672229">(Jun 06 2021 at 04:36)</a>:</h4>
<p>I would expect the overhead to be less than cloning the CStore, but I don't have any data to back it up.</p>



<a name="241672246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672246">(Jun 06 2021 at 04:37)</a>:</h4>
<p>I was thinking about the overhead for regular compilation.</p>



<a name="241672249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672249">(Jun 06 2021 at 04:37)</a>:</h4>
<p>regular compilation also clones the CStore.</p>



<a name="241672254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672254">(Jun 06 2021 at 04:37)</a>:</h4>
<p>err hmm no I think you're right, Rc::try_unwrap will succeed when rustdoc isn't running</p>



<a name="241672303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672303">(Jun 06 2021 at 04:38)</a>:</h4>
<p>It currently doesn't go through an indirection when accessing resolver outputs from TyCtxt.</p>



<a name="241672309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672309">(Jun 06 2021 at 04:38)</a>:</h4>
<p>oh, you mean because with the new setup the TyCtxt would have to call <code>resolver_outputs()</code> each time</p>



<a name="241672318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672318">(Jun 06 2021 at 04:39)</a>:</h4>
<p>if that turns out to be an issue I can add a function for each individual output, that should reduce the boxing/cloning</p>



<a name="241672450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672450">(Jun 06 2021 at 04:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Don't.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437/near/241669799">said</a>:</p>
<blockquote>
<p>I have some (very broken) WIP code, I will try to push it somewhere before I go to bed so you can get an idea of what the changes look like.</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/compare/master...jyn514:no-steal?expand=1">https://github.com/rust-lang/rust/compare/master...jyn514:no-steal?expand=1</a></p>



<a name="241672793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241672793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241672793">(Jun 06 2021 at 04:53)</a>:</h4>
<p>I could also have it return borrows instead of owned values, that should make things a lot faster and only the boxing will be left</p>



<a name="241673096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241673096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241673096">(Jun 06 2021 at 05:00)</a>:</h4>
<p>Before I forget: the current setup will cause BorrowMut errors when rustdoc tries to access the resolver; instead I can implement ty::Resolver for Queries and pass that in.</p>
<p>To reduce the overhead further I could pass in ResolverOutputs directly when rustdoc isn't running, but that requires more <code>actually_rustdoc</code> special casing so I'd rather not unless the perf difference is really bad.</p>



<a name="241683009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241683009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241683009">(Jun 06 2021 at 09:35)</a>:</h4>
<p>I don't think this is a good idea, and I still think <a href="https://github.com/rust-lang/rust/issues/83761">https://github.com/rust-lang/rust/issues/83761</a> is preferable and also easier to implement.</p>



<a name="241683158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241683158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241683158">(Jun 06 2021 at 09:39)</a>:</h4>
<p>With frozen resolver you cannot do pretty much anything, and modifying resolver is dangerous because it's not covered by query system and its changes are not tracked.</p>



<a name="241683227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241683227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241683227">(Jun 06 2021 at 09:41)</a>:</h4>
<p>Integrating name resolution into incremental/queries is a large future task, and fixing <a href="https://github.com/rust-lang/rust/issues/83761">#83761</a> by collecting doc links in rustdoc earlier should be a much simpler task.</p>



<a name="241685502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241685502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241685502">(Jun 06 2021 at 10:44)</a>:</h4>
<p>This MCP could be a first step towards this integration, as a baby step, and would unlock querifying HIR lowering.</p>



<a name="241689963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241689963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241689963">(Jun 06 2021 at 12:41)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> fixing this in Rustdoc is <em>not</em> easier to implement, I made more progress in the three hours I played around last night than in the 2 weeks I spent on the rustdoc approach.</p>
<blockquote>
<p>modifying resolver is dangerous because it's not covered by query system and its changes are not tracked</p>
</blockquote>
<p>Hmm, you mean rustdoc modifying the resolver is dangerous? Rustdoc doesn't modify the incremental cache so I'm not <em>super</em> worried about that:</p>
<div class="codehilite" data-code-language="Bash Session"><pre><span></span><code><span class="gp">$ </span>rm -r target
<span class="gp">$ </span>cargo doc
<span class="go"> Documenting hello-world v0.1.0 (/home/joshua/src/rust/hello-world)</span>
<span class="go">    Finished dev [unoptimized + debuginfo] target(s) in 2.41s</span>
<span class="gp">$ </span>ls target/debug/incremental/
<span class="gp">$</span>
</code></pre></div>
<p>My proposed scheme with <code>trait Resolver</code> wouldn't allow modifying the resolver through the TyCtxt, so it shouldn't be an issue for rustc itself.</p>
<blockquote>
<p>With frozen resolver you cannot do pretty much anything</p>
</blockquote>
<p>This is the existing situation, not my proposed change, right?</p>



<a name="241690078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241690078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241690078">(Jun 06 2021 at 12:43)</a>:</h4>
<p>The associated GitHub issue has been renamed. Renaming this Zulip topic.</p>



<a name="241690226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241690226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241690226">(Jun 06 2021 at 12:46)</a>:</h4>
<p>I updated the MCP with the discussion in this thread to make it more clear the TyCtxt won't have mutable access.</p>



<a name="241690583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/241690583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#241690583">(Jun 06 2021 at 12:55)</a>:</h4>
<blockquote>
<p>Hmm, you mean rustdoc modifying the resolver is dangerous? Rustdoc doesn't modify the incremental cache so I'm not super worried about that:</p>
</blockquote>
<p>I guess the way this could go wrong is, within the same rustdoc invocation:</p>
<ol>
<li>TyCtxt is created</li>
<li>Rustdoc runs a query that depends on resolve info (maybe DefIds? I don't know what can actually change; my understanding is that the resolver doesn't update DefIds even when more crates are loaded)</li>
<li>Rustdoc loads a new crate</li>
<li>Rustdoc reruns the query, and the TyCtxt gives it the cached old value, but it may have changed based on the new crate</li>
</ol>
<p>I am ok with that risk, it only affects rustdoc and it seems like something we could work around.</p>



<a name="242421770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/242421770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#242421770">(Jun 12 2021 at 02:23)</a>:</h4>
<p>any further thoughts on this? having this be broken is causing lots of rustdoc regressions (in particular the mess in <a href="https://github.com/rust-lang/rust/pull/84867">https://github.com/rust-lang/rust/pull/84867</a>)</p>



<a name="242526588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/242526588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#242526588">(Jun 13 2021 at 19:26)</a>:</h4>
<p>What is the source of the regressions?<br>
If it's <a href="https://github.com/rust-lang/rust/pull/83738">https://github.com/rust-lang/rust/pull/83738</a> then feel free to land <a href="https://github.com/rust-lang/rust/pull/85749">https://github.com/rust-lang/rust/pull/85749</a> if it's needed for the upcoming release.<br>
I still plan to investigate the underlying issues behind it (<a href="https://github.com/rust-lang/rust/issues/84738">https://github.com/rust-lang/rust/issues/84738</a>), but I was busy during the last weeks and now I'm on vacation.</p>



<a name="242527385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/242527385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#242527385">(Jun 13 2021 at 19:48)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> the one I was thinking of was <a href="https://github.com/rust-lang/rust/issues/82465">https://github.com/rust-lang/rust/issues/82465</a>, which has a fix in <a href="https://github.com/rust-lang/rust/pull/82496">https://github.com/rust-lang/rust/pull/82496</a> but can't be merged because of the inconsistent crate loading. I guess "causing regressions" is incorrect, but it is true that the whole mess would be cleared up if this were fixed.</p>



<a name="242527397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/242527397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#242527397">(Jun 13 2021 at 19:49)</a>:</h4>
<p>(<a href="https://github.com/rust-lang/rust/pull/84867">https://github.com/rust-lang/rust/pull/84867</a> is a giant mess that has landed on some channels but not others; there's info in <a href="#narrow/stream/241545-t-release/topic/how.20to.20track.20ETA.20when.20nightly.20will.20be.20cut.20to.20beta/near/242135597">https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/how.20to.20track.20ETA.20when.20nightly.20will.20be.20cut.20to.20beta/near/242135597</a> if you really want to know)</p>



<a name="242527449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/242527449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#242527449">(Jun 13 2021 at 19:50)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116083">@pnkfelix</span> I guess, but there's nothing actionable here for you</p>



<a name="243023608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243023608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243023608">(Jun 17 2021 at 14:15)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I'm a bit confused by this -- we are storing a "read-only view" of the resolver in the tyctxt, is the idea, but mutation is still possible?</p>



<a name="243026686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243026686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243026686">(Jun 17 2021 at 14:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> mutation is possible, but only through Queries, not through TyCtxt</p>



<a name="243026763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243026763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243026763">(Jun 17 2021 at 14:35)</a>:</h4>
<p>That makes it effectively read-only for most of the compiler, but still lets rustdoc mutate it and have the compiler see the changes.</p>



<a name="243200991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243200991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243200991">(Jun 18 2021 at 19:42)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> This is definitely contra to the design of incremental; what kind of mutations do we expect?</p>



<a name="243201356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243201356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243201356">(Jun 18 2021 at 19:46)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think the only mutations should be new crates loaded after HIR is built, and new DefIds registered within that crate.</p>
<p>Are you saying this is contrary to the design because resolutions aren't tracked by the query system? I wouldn't expect them to inherently not fit because the whole point of incremental is to delay things as long as possible.</p>



<a name="243201392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243201392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243201392">(Jun 18 2021 at 19:47)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> may have more insight into what can change after the TyCtxt is created.</p>



<a name="243789196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243789196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243789196">(Jun 24 2021 at 13:54)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I'm reading more about this, playing catch up on the threads. What does "partial resolution" mean, as referenced in <a href="https://github.com/rust-lang/rust/issues/83761#issuecomment-812968168">your github comment</a>?</p>



<a name="243789357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243789357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243789357">(Jun 24 2021 at 13:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Don't.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437/near/243201356">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> I think the only mutations should be new crates loaded after HIR is built, and new DefIds registered within that crate.</p>
</blockquote>
<p>Does this imply that rustdoc has control-flow paths that loads new crates after HIR is built, and these control-flow paths do not exist in rustc itself?</p>



<a name="243789494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243789494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243789494">(Jun 24 2021 at 13:56)</a>:</h4>
<blockquote>
<p>Does this imply that rustdoc has control-flow paths that loads new crates after HIR is built, and these control-flow paths do not exist in rustc itself?</p>
</blockquote>
<p>Yes. Intra-doc links can link to items that are not used otherwise.</p>



<a name="243789710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243789710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243789710">(Jun 24 2021 at 13:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Don't.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437/near/243789196">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> I'm reading more about this, playing catch up on the threads. What does "partial resolution" mean, as referenced in <a href="https://github.com/rust-lang/rust/issues/83761#issuecomment-812968168">your github comment</a>?</p>
</blockquote>
<p>It's kind of a implementation detail of the strategy I was using there, which didn't work out. The idea was to do the path-based resolution before the TyCtxt was created and the type-based resolution after, which required splitting the whole intra-doc pass into two. I am no longer pursuing that approach.</p>



<a name="243790139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243790139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243790139">(Jun 24 2021 at 14:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Don't.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437/near/243789494">said</a>:</p>
<blockquote>
<blockquote>
<p>Does this imply that rustdoc has control-flow paths that loads new crates after HIR is built, and these control-flow paths do not exist in rustc itself?</p>
</blockquote>
<p>Yes. Intra-doc links can link to items that are not used otherwise.</p>
</blockquote>
<p>this is actually the whole reason for the ICEs, if we didn't support this it wouldn't be an issue. But that's already on stable so I don't think we can change it now :/ and it seems confusing to have to add imports for rustdoc when things would work fine in code.</p>



<a name="243791243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243791243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243791243">(Jun 24 2021 at 14:07)</a>:</h4>
<p>another possible alternative is to do this in the opposite order: store <em>only</em> a read-only resolver on TyCtxt, start tracking changes to it in the query system, and only then allow rustdoc to mutate it. That's a lot more time and effort, but it seems more correct and inline with the compiler's long-term goals</p>



<a name="243791319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243791319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243791319">(Jun 24 2021 at 14:08)</a>:</h4>
<p>I would need mentoring to work on that I think, but I can put in some time on weekends.</p>



<a name="243795936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243795936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243795936">(Jun 24 2021 at 14:40)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> </p>
<blockquote>
<p>It's kind of a implementation detail of the strategy I was using there, which didn't work out. The idea was to do the path-based resolution before the TyCtxt was created and the type-based resolution after, which required splitting the whole intra-doc pass into two.</p>
</blockquote>
<p>Why didn't it work out?<br>
This is the approach that rustc uses, quite successfully.<br>
I still think this is what rustdoc should do as well.</p>



<a name="243796058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243796058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243796058">(Jun 24 2021 at 14:41)</a>:</h4>
<p>it was several weeks of work, and each change I made made me realize how much more work it was going to be. I don't have to work on it now and I don't think anyone else does either.</p>



<a name="243796126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243796126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243796126">(Jun 24 2021 at 14:42)</a>:</h4>
<p>(full-time weeks, not "a weekend each week")</p>



<a name="243796303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243796303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243796303">(Jun 24 2021 at 14:43)</a>:</h4>
<p>I don't say that it will be easy, because rustdoc has been consistently painting itself into corners for years by inventing custom hygiene rules for intra-doc links, and doing other horrifying stuff, but it's still the easiest thing to do (and a proper one, I think).</p>



<a name="243796538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243796538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243796538">(Jun 24 2021 at 14:45)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> I personally am not willing to work on it</p>



<a name="243797152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243797152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243797152">(Jun 24 2021 at 14:49)</a>:</h4>
<p>I will note that the hard part is the error reporting, not the hygiene rules. Splitting the pass means all <em>potential</em> failures have to be resolved up front too.</p>



<a name="243797234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243797234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243797234">(Jun 24 2021 at 14:49)</a>:</h4>
<p>and rustdoc has more constraints than resolve because it doesn't know what namespace the item belongs in.</p>



<a name="243797256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243797256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243797256">(Jun 24 2021 at 14:49)</a>:</h4>
<p>(At this point this issue annoys me enough to be willing to work on it, the problem is that I don't have time.)</p>



<a name="243798080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243798080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243798080">(Jun 24 2021 at 14:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Don't.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437/near/243797152">said</a>:</p>
<blockquote>
<p>I will note that the hard part is the error reporting, not the hygiene rules. Splitting the pass means all <em>potential</em> failures have to be resolved up front too.</p>
</blockquote>
<p>Could you elaborate, what is the problem exactly?<br>
If the exact namespace is not known, then the path can be resolved in all namespaces, all partial resolutions can be saved for later if necessary, all procuced errors can be saved for later if necessary as well.</p>



<a name="243798422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243798422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243798422">(Jun 24 2021 at 14:57)</a>:</h4>
<p>It's out of cache for me. I'd have to look at the errors on <a href="https://github.com/jyn514/rust/commit/8d3d43f3a1a97739505d03430972ff08e1667a23">https://github.com/jyn514/rust/commit/8d3d43f3a1a97739505d03430972ff08e1667a23</a>.</p>



<a name="243799328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Don%27t%20steal%20the%20resolver%20when%20lowering%20HI%E2%80%A6%20compiler-team%23437/near/243799328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Don&#x27;t.20steal.20the.20resolver.20when.20lowering.20HI.E2.80.A6.20compiler-team.23437.html#243799328">(Jun 24 2021 at 15:02)</a>:</h4>
<p>I see, I guess I'll have to look at it myself anyway to really understand what's the problem.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>